<?php
namespace app\push\controller;
use Workerman\Worker;
use GatewayWorker\Register;
use GatewayWorker\BusinessWorker;
use GatewayWorker\Gateway;
class Run{
//控制器无需继承Controller
/**
* 构造函数
* @access public
*/
public function __construct(){
$filePath = __DIR__."/../swp/noninit.txt";
if(!is_file($filePath)){
    $file = fopen($filePath,'w');
    fclose($file);
}
//初始化各个GatewayWorker */
//1.初始化register
new Register('text://0.0.0.0:1238');
//2.初始化 bussinessWorker 进程
$worker = new BusinessWorker();
$worker->name = 'YourAppBusinessWorker';
$worker->count = 4;
$worker->registerAddress = '127.0.0.1:1238';
//3.设置处理业务的类,此处制定Events的命名空间
$worker->eventHandler = '\app\push\controller\Event';
//4.初始化 gateway 进程
$gateway = new Gateway("websocket://0.0.0.0:8282");
$gateway->name = 'YourAppGateway';
$gateway->count = 4;
$gateway->lanIp = '127.0.0.1';
$gateway->startPort = 2900;
$gateway->registerAddress = '127.0.0.1:1238';
//运行所有Worker;
Worker::runAll();
    }
}
